import logo from './logo.svg';
import './App.less';
import { Button } from 'antd';
import {BrowserRouter as Router, Link, Navigate, Route, Routes, Outlet} from "react-router-dom";
import Main from "./pages/Main";
import Login from "./pages/Login"
import Page1 from "./pages/Page1";
import Page2 from "./pages/Page2";
import Scada from "./pages/scada";
import ScadaPage3 from "./pages/Page3";
import React from "react";
import { ConfigProvider } from 'antd';
import {ReadExpire} from "./Utils/Storage";
import {WriteExpire} from "./Utils/Storage";
//let g_isAuthenticated = false;
import {isAuthenticated} from "./Auth/authenticate";
const PrivateRoutes = () => {
    //let auth = {'token':true}
    return (
        isAuthenticated() ? <Outlet/> : <Navigate to='/Login'/>
    )
}

function App() {
  return (
      <div>
          <Router>
              {/*
          A <Switch> looks through all its children <Route>
          elements and renders the first one whose path
          matches the current URL. Use a <Switch> any time
          you have multiple routes, but you want only one
          of them to render at a time
        */}

              <Routes>
                  <Route element={<PrivateRoutes/>}>
                      <Route  exact path='/Main' element={<Main />}/>
                      <Route  exact path='/Page1' element={<Page1 />}/>
                  </Route>
                  <Route exact path='/Login' element={<Login/>}/>
                  <Route exact path='/*' element={<Navigate to='/Login'/>}/>
              </Routes>
          </Router>
      </div>

  );
}

export default App;
